# Confirmation Mode and Security Analyzers

OpenHands provides a security framework to help protect users from potentially risky actions through **Confirmation Mode** and **Security Analyzers**. This system analyzes agent actions and prompts users for confirmation when high-risk operations are detected.

## Overview

The security system consists of two main components:

1. **Confirmation Mode**: When enabled, the agent will pause and ask for user confirmation before executing actions that are flagged as high-risk by the security analyzer.

2. **Security Analyzers**: These are modules that evaluate the risk level of agent actions and determine whether user confirmation is required.

## Configuration

### CLI
In CLI mode, confirmation is enabled by default. You will have an option to uses the LLM Analyzer and will automatically confirm LOW and MEDIUM risk actions, only prompting for HIGH risk actions.

## Security Analyzers

OpenHands includes multiple analyzers:

- **No Analyzer**: Do not use any security analyzer. The agent will prompt you to confirm *EVERY* action.
- **LLM Risk Analyzer** (default): Uses the same LLM as the agent to assess action risk levels
- **Invariant Analyzer**: Uses Invariant Labs' policy engine to evaluate action traces against security policies

### LLM Risk Analyzer
The default analyzer that leverages the agent's LLM to evaluate the security risk of each action. It considers the action type, parameters, and context to assign risk levels.

### Invariant Analyzer
An advanced analyzer that:
- Collects conversation events and parses them into a trace
- Checks the trace against an Invariant policy to classify risk (low, medium, high)
- Manages an Invariant server container automatically if needed
- Supports optional browsing-alignment and harmful-content checks

## How It Works

1. **Action Analysis**: When the agent wants to perform an action, the selected security analyzer evaluates its risk level.

2. **Risk Assessment**: The analyzer returns one of three risk levels:
   - **LOW**: Action proceeds without confirmation
   - **MEDIUM**: Action proceeds without confirmation (may be configurable in future)
   - **HIGH**: Action is paused, and user confirmation is requested

3. **User Confirmation**: For high-risk actions, a confirmation dialog appears with:
   - Description of the action
   - Risk assessment explanation
   - Options to approve or deny action

4. **Action Execution**: Based on user response:
   - **Approve**: Action proceeds as planned
   - **Deny**: Action is cancelled
